Skip to content

KubeJS Compat ​

Epiphany provides full KubeJS compatibility, allowing modpack authors to listen to events, call APIs, and query data through JavaScript scripts. All functionality is registered via the standard KubeJS plugin mechanism.

TIP

All scripts reside in the server_scripts/ directory and run on the server side only.

INFO

All concepts introduced in this section correspond one-to-one with Custom Events and Manager API. Unless otherwise noted, behavior is identical to the Java side.

Overview ​

Epiphany provides two entry points via the KubeJS plugin:

NamespacePurposeSource
EpiphanyEvents.*Listen to events (15 events related to Module/Insight/Epiphany/Aptitude)KubeJS EventGroup
Epiphany.*Call API (Manager methods + data queries)KubeJS Binding

Namespace separation

Event listening uses EpiphanyEvents.*, API calls use Epiphany.*. The two are deliberately placed in different namespaces to avoid name collisions.

Plugin entry point: ink.myumoon.epiphany.event.kubejs.EpiphanyKubeJSPlugin, discovered via kubejs.plugins.txt.

Events (EpiphanyEvents.*) ​

All events carry a player field (ServerPlayer). Each event carries relevant id fields (e.g., moduleId, insightId, epiphanyId) for scripts to read.

Naming Convention ​

SuffixMeaningCancellable
Present tense (e.g., moduleUnlock, moduleSelect, moduleComplete)Pre event, cancel with event.cancel()✅
Past tense (e.g., moduleUnlocked, moduleSelected, moduleCompleted)Post event, notification only❌

Cancellation mechanism

Pre events are cancelled using KubeJS-standard event.cancel(), not the Java-side setCanceled(true). The plugin internally bridges to native NeoForge events.

Module Events ​

Event NameTypeWhen It Fires
moduleUnlockPre (cancellable)Module is about to be unlocked
moduleUnlockedPostModule has been unlocked
moduleSelectPre (cancellable)Module is about to be selected
moduleSelectedPostModule has been selected
moduleCompletePre (cancellable)Module is about to be completed
moduleCompletedPostModule has been completed

Insight Events ​

Cascading

After insightSelected fires, if all insights in the owning module are now unlocked, it automatically chains into Module's moduleComplete / moduleCompleted. A single insightSelect call can trigger a full 4-event chain.

Event NameTypeDescription
insightSelectPre (cancellable)Insight is about to be unlocked
insightSelectedPostInsight has been unlocked

Epiphany Events ​

Event NameTypeDescription
epiphanyUnlockPre (cancellable)Epiphany is about to be unlocked
epiphanyUnlockedPostEpiphany has been unlocked
epiphanySelectPre (cancellable)Epiphany is about to be activated
epiphanySelectedPostEpiphany has been activated

Aptitude Events (All Post) ​

Trigger frequency differences

aptitudeLevelUp fires once per +1 Insight Point (one addAptitude call can trigger it multiple times). In contrast, insightPointsChanged is a settlement-level event — regardless of how many internal level-ups occur in one call, it fires only once. Use the latter for notifications, the former for per-point tracking.

Event NameDescription
aptitudeChangedWhen aptitude value changes
aptitudeLevelUpWhen the bar fills and an Insight Point is earned (once per +1)
insightPointsChangedWhen the Insight Point balance changes (settlement-level, once per call)

Bindings (Epiphany.*) ​

All methods execute synchronously on the server side. The player parameter must be of type ServerPlayer.

Utilities ​

js
Epiphany.id(namespace, path)   // Construct a ResourceLocation
Epiphany.id('mymod', 'foo')    // → 'mymod:foo'

You can also use KubeJS string literals like 'mymod:foo' — both are equivalent.

Module ​

MethodDescription
isModuleUnlocked(player, id)Query: is the module unlocked?
isModuleSelected(player, id)Query: is the module selected?
isModuleCompleted(player, id)Query: is the module completed?
moduleUnlock(player, id)Unlock the module
moduleLock(player, id)Lock the module
moduleSelect(player, id)Select the module (consumes Insight Points)
moduleForceSelect(player, id)Force select (ignores cost/conditions/cap)
moduleComplete(player, id)Complete the module (requires all insights unlocked)
moduleForceComplete(player, id)Force complete
moduleReset(player, id)Reset the module (refunds Insight Points, removes rewards)

Insight ​

MethodDescription
isInsightSelected(player, id)Query: is the insight unlocked?
isInsightModuleSelected(player, id)Query: is the insight's owning module selected?
insightSelect(player, insightId, moduleId)Unlock the insight (consumes Insight Points)
insightForceSelect(player, insightId, moduleId)Force unlock (ignores cost/prerequisites)
insightReset(player, id)Reset the insight

Epiphany ​

MethodDescription
isEpiphanyUnlocked(player, id)Query: is the epiphany unlocked?
isEpiphanySelected(player, id)Query: is the epiphany activated?
epiphanyUnlock(player, id)Unlock the epiphany
epiphanyLock(player, id)Lock the epiphany
epiphanySelect(player, id)Activate the epiphany (consumes 1 slot)
epiphanyForceSelect(player, id)Force activate (ignores slot limits)
epiphanyReset(player, id)Reset the epiphany

Tools ​

MethodReturnsDescription
getEpiphanySlots(player)intEpiphany Slots unlocked by the player
getUsedEpiphanySlots(player)intEpiphany Slots currently occupied
getMaxEpiphanySlots()intConfigured hard cap on selectable Epiphanies
getSelectedModuleCount(player)intModules the player currently has selected
getMaxSelectedModules()intConfigured hard cap on simultaneously selected Modules

Reset ​

MethodDescription
resetAll(player)Remove all rewards and Epiphany data, then restore initially SELECTABLE entries
resetSelections(player)Clear selections and rewards, preserve aptitude, refund selection costs, then restore initially SELECTABLE entries

Event behavior

These methods are equivalent to /epiphany reset all and /epiphany reset select. They intentionally fire no aptitude, Insight Point, or selection events.

Aptitude / Points ​

MethodReturnsDescription
getAptitude(player)longCurrent aptitude
getInsightPoints(player)intAvailable Insight Points
getTotalInsightPointsSpent(player)intTotal Insight Points spent
getTotalInsightPoints(player)longSpent and unspent Insight Points combined
canGainInsightPoints(player)booleanWhether the player can gain more aptitude and points; false at the total cap
setAptitude(player, value)—Set aptitude; increases use the growth curve, decreases do not take back points
addAptitude(player, amount)—Add the specified aptitude without the gain multiplier; use the growth curve to level up and retain the remainder
addAptitudeWithMultiplier(player, amount)—Add aptitude after applying the player's aptitude_gain_multiplier; the scaled amount is rounded down
setInsightPoints(player, value)—Set available points without changing spent points; increases obey the total cap
addInsightPoints(player, amount)—Add or subtract points, with a minimum balance of 0; increases obey the total cap
fillAptitude(player)longTop up to the next point using the growth curve; return the aptitude added, or 0 at the cap
getRequiredForNextPoint(player)longGet the aptitude threshold for the player's next Insight Point
calcRequiredAptitude(totalSpent, points)longCalculate the next point's cost using the server's current growth curve

The total cap counts spent + unspent points. These methods use the same settlement rules as the Java API: one aptitude grant can earn multiple points, with the remainder retained. Progression stops at the total cap, and excess aptitude is discarded when the cap is reached. Normal spending and corresponding refunds preserve total points; direct deductions lower the total. See Growth Curve for configuration.

Aptitude Source (Custom Aptitude Sources) ​

MethodReturnsDescription
grantAptitude(player, behaviorId, targetId, registry)booleanRoll regular and first-time rewards per datapack rules, apply the player multiplier once to their sum, and return whether a grant succeeded
resolveAptitudeSource(player, behaviorId, targetId, registry)ResolutionQuery reward ranges without rolling, applying the multiplier, or claiming a first-time reward

For tag matching, pass the target's registry as registry. Pass null when matching concrete IDs only; tags will not match. For example, item targets use Java.loadClass('net.minecraft.core.registries.BuiltInRegistries').ITEM. See Registering a New Aptitude Source.

Use baseReward() and firstReward() to inspect the regular and available first-time reward ranges separately, or minReward() / maxReward() for their combined bounds:

js
let result = Epiphany.resolveAptitudeSource(
    player,
    Epiphany.id('mymod', 'fishing'),
    Epiphany.id('minecraft', 'cod'),
    null
);
if (result.applies()) {
    console.info('Base reward range: ' + result.minReward() + '–' + result.maxReward());
}

Here, player is a server player provided by an event. applies() indicates that the rules allow a positive reward. Use Epiphany.canGainInsightPoints(player) to check whether the player is capped. The old result.reward() is deprecated and works only for fixed values; query bounds for random rewards, and call grantAptitude to issue them.

See Aptitude & Insight Point for range formats and first-time reward rules.

Data Queries (Datapack Registry) ​

Look up one datapack-defined entry by ID. Returns null when not found:

MethodReturn Type
getModule(id)ModuleData
getInsight(id)InsightData
getEpiphany(id)EpiphanyData
getPath(id)PathData

You can also list every registered Module, Epiphany, or Insight:

MethodReturn TypeDescription
allModuleIds()ResourceLocation[]All Module IDs, sorted
allModules()ModuleData[]All Module definitions
allEpiphanyIds()ResourceLocation[]All Epiphany IDs, sorted
allEpiphanies()EpiphanyData[]All Epiphany definitions
allInsightIds()ResourceLocation[]All Insight IDs, sorted
allInsights()InsightData[]All Insight definitions

Iterate as arrays

The bulk query methods return Java arrays rather than Lists. Use indexed access in KubeJS; Rhino's List.get(i) can return incorrect elements.

js
let ids = Epiphany.allModuleIds();
for (let i = 0; i < ids.length; i++) {
    console.info(ids[i]);
}

let insights = Epiphany.allInsights();
for (let i = 0; i < insights.length; i++) {
    console.info(insights[i].cost());
}

The returned records' fields can be accessed directly. For example:

js
let module = Epiphany.getModule('mymod:combat');
if (module) {
    console.info(module.name);          // Optional<Component>
    console.info(module.description);   // Optional<Component>
    console.info(module.initialState);  // 'locked' or 'selectable'
    console.info(module.weight);        // number
    module.insights.forEach(entry => {
        console.info(entry.id, entry.depth);  // insight ID + depth
    });
}

Optional fields and lang fallback

The name, description, and *_description fields exposed on records are raw Optionals — they contain whatever was written in the datapack JSON, without applying the default lang fallback logic. For example:

  • module.name → Optional<Component>, may be empty (if JSON omitted name)
  • module.name.get().getString() → returns the JSON literal (or translation key string), but does not go through lang translation fallback

If you provide multilingual support via resource packs, use each data type's effectiveXxx(id) method:

js
let id = 'mymod:combat';
let module = Epiphany.getModule(id);
if (module) {
    // Raw — may be empty
    let rawName = module.name;  // Optional<Component>

    // Resolved — goes through full lang fallback chain
    let displayName = module.effectiveName(id).getString();
    let displayDesc = module.effectiveDescription(id).getString();
}

Each type's effectiveXxx methods correspond to its Component fields (name, description, condition_description, reward_description, etc.). When omitted, they look up the conventional translation keys in assets/<ns>/lang/*.json. See Module · Text Components & i18n for naming rules.

KubeJS Stage Condition ​

Epiphany provides condition and reward types based on KubeJS Stages for use in datapack JSON:

json
{ "type": "epiphany:kubejs_stage", "stage": "nether_access" }

The condition passes when the player has the specified KubeJS Stage. Without KubeJS installed, it always returns false without crashing.

Example Scripts ​

Welcome Reward on Module Selection ​

js
// server_scripts/welcome.js

EpiphanyEvents.moduleSelected(event => {
    let player = event.player;
    let moduleId = event.moduleId;

    // Notify the player
    player.tell('You selected module: ' + moduleId);

    // Give an iron sword on the first selection of the combat module
    if (moduleId === 'mymod:combat') {
        let hasClaimed = player.stages.has('combat_welcome');
        if (!hasClaimed) {
            player.give('minecraft:iron_sword');
            player.stages.add('combat_welcome');
            player.tell('Welcome to the warrior path! Received: Iron Sword x1');
        }
    }
});

Pre Event: Prevent Module Selection ​

js
// server_scripts/restrict.js

EpiphanyEvents.moduleSelect(event => {
    let player = event.player;

    // Prevent module selection during a boss fight
    if (player.stages.has('boss_fight_active')) {
        event.cancel();
        player.tell('A boss fight is in progress. You cannot select a new module.');
    }
});

// The same rule applies to epiphanies
EpiphanyEvents.epiphanySelect(event => {
    if (event.player.stages.has('boss_fight_active')) {
        event.cancel();
    }
});

Aptitude Tracking and Notifications ​

js
// server_scripts/aptitude_notify.js

// Notify the player when Insight Points are gained
EpiphanyEvents.insightPointsChanged(event => {
    if (event.isGain) {
        event.player.tell(
            'Insight Points gained! Current: ' + event.newValue + ' (+' + event.delta + ')'
        );
    }
});

// Track each aptitude level-up separately
let levelUpCounter = {};
EpiphanyEvents.aptitudeLevelUp(event => {
    let uuid = event.player.uuid;
    levelUpCounter[uuid] = (levelUpCounter[uuid] || 0) + 1;
    // Give a reward every 10 level-ups
    if (levelUpCounter[uuid] % 10 === 0) {
        event.player.give('minecraft:diamond');
    }
});

Managing Player Data Through the API ​

js
// server_scripts/admin_helper.js

PlayerEvents.loggedIn(event => {
    let player = event.player;

    // Query progress
    let pts = Epiphany.getInsightPoints(player);
    let apt = Epiphany.getAptitude(player);
    console.info('[Epiphany] ' + player.name + ' Insight Points=' + pts + ', Aptitude=' + apt);

    // Give 100 aptitude on the first login
    if (!player.stages.has('epiphany_gift') && Epiphany.canGainInsightPoints(player)) {
        Epiphany.addAptitude(player, 100);
        player.stages.add('epiphany_gift');
        player.tell('Welcome gift claimed. Check your aptitude and Insight Points.');
    }
});

Querying Datapack Definitions ​

js
// server_scripts/inspect.js

// List a module's insights and their depths
let moduleId = 'mymod:combat';
let module = Epiphany.getModule(moduleId);
if (!module) {
    console.warn('Module not found: ' + moduleId);
} else {
    console.info('Module: ' + moduleId + ', weight=' + module.weight);
    module.insights.forEach(entry => {
        let insight = Epiphany.getInsight(entry.id);
        if (!insight) {
            console.info('  - depth=' + entry.depth + ': ' + entry.id + ' → (missing)');
        } else {
            let desc = insight.effectiveDescription(entry.id.toString()).getString();
            console.info('  - depth=' + entry.depth + ': ' + entry.id + ' → ' + desc);
        }
    });
}

Custom Aptitude Sources ​

This example calls a custom mymod:module_completion behavior when a module is completed, using the module ID as its target. First, add the datapack definition:

jsonc
// data/mymod/epiphany/aptitude/module_completion.json
{
    "default": [2, 5],
    "specials": [
        {
            "target": "mymod:combat",
            "reward": [8, 12],
            "first_reward": 30
        }
    ]
}

Then add a server script:

js
// server_scripts/custom_aptitude.js

EpiphanyEvents.moduleCompleted(event => {
    Epiphany.grantAptitude(
        event.player,
        Epiphany.id('mymod', 'module_completion'),
        event.moduleId,
        null
    );
});

This example matches concrete module IDs, so registry is null. The first completion of mymod:combat grants a combined regular and first-time reward of 38–42 aptitude before the player multiplier. The system tracks first-time rewards by player, behavior, and target, so no separate Stage is needed. At the total point cap, nothing is granted and the first-time reward is not consumed.

Epiphany already provides the epiphany:module_completed behavior. To adjust its aptitude reward, configure that behavior's JSON directly. The example above is for cases where a script needs to trigger a separate reward.